package com.mt.sqlsession;

import com.mt.config.MyConfiguration;

import java.lang.reflect.Proxy;

/**
 * @Author : fang.com
 * @CreatTime : 2020-12-07 15:33
 * @Description :
 * @Version :  0.0.1
 */
public class MySqlsession {

    private Excutor excutor= new MyExcutor();

    private MyConfiguration myConfiguration = new MyConfiguration();

    public <T> T selectOne(String statement,Object parameter){
        return excutor.query(statement, parameter);
    }

    @SuppressWarnings("unchecked")
    public <T> T getMapper(Class<T> clas){
        //动态代理调用
        return (T) Proxy.newProxyInstance(clas.getClassLoader(),new Class[]{clas},
                new MyMapperProxy(myConfiguration,this));
    }   }
